/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author selam
 */
@Entity
@Table(name = "personalpackage")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Personalpackage.findAll", query = "SELECT p FROM Personalpackage p"),
    @NamedQuery(name = "Personalpackage.findByPPackageId", query = "SELECT p FROM Personalpackage p WHERE p.pPackageId = :pPackageId")})
public class Personalpackage implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "PPackageId")
    private Integer pPackageId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pPackageId")
    private Collection<Modificaton> modificatonCollection;
    @JoinColumn(name = "GPackageId", referencedColumnName = "GPackageId")
    @ManyToOne(optional = false)
    private Generalpackage gPackageId;
    @JoinColumn(name = "User_Id", referencedColumnName = "User_Id")
    @ManyToOne(optional = false)
    private User userId;

    public Personalpackage() {
    }

    public Personalpackage(Integer pPackageId) {
        this.pPackageId = pPackageId;
    }

    public Integer getPPackageId() {
        return pPackageId;
    }

    public void setPPackageId(Integer pPackageId) {
        this.pPackageId = pPackageId;
    }

    @XmlTransient
    public Collection<Modificaton> getModificatonCollection() {
        return modificatonCollection;
    }

    public void setModificatonCollection(Collection<Modificaton> modificatonCollection) {
        this.modificatonCollection = modificatonCollection;
    }

    public Generalpackage getGPackageId() {
        return gPackageId;
    }

    public void setGPackageId(Generalpackage gPackageId) {
        this.gPackageId = gPackageId;
    }

    public User getUserId() {
        return userId;
    }

    public void setUserId(User userId) {
        this.userId = userId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pPackageId != null ? pPackageId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Personalpackage)) {
            return false;
        }
        Personalpackage other = (Personalpackage) object;
        if ((this.pPackageId == null && other.pPackageId != null) || (this.pPackageId != null && !this.pPackageId.equals(other.pPackageId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Personalpackage[ pPackageId=" + pPackageId + " ]";
    }
    
}
